/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package components.shapemenu;

import PCR.MainFrame;
import PCR.ShapesDialog;
import components.Band;
import components.Dimer;
import components.Smear;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;

/**
 *
 * @author icdev
 */
public class MenuAction implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        MainFrame frm = (MainFrame) java.awt.Window.getWindows()[0];
        JMenuItem curMenu = (JMenuItem) e.getSource();
        if (curMenu.getText().equals("Delete")) {
            if (frm.getSeletedShape() != null) {
                frm.getSeletedShape().getParent().remove(frm.getSeletedShape());
                frm.repaint();
                frm.setSelectedShape(null);
            }
        } else if (curMenu.getText().equals("Change Shape")) {
            String sType = "";
            ShapesDialog shd = new ShapesDialog(frm, true);
            if (frm.getSeletedShape() instanceof Band) {
                sType = "Bands";
            } else if (frm.getSeletedShape() instanceof Smear) {
                sType = "Smears";
            } else if (frm.getSeletedShape() instanceof Dimer) {
                sType = "Dimers";
            }
            ShapesDialog.setReplacer(true);
            shd.loadShapes(sType);

            shd.setTitle(sType);
            shd.setVisible(true);
        } else if (curMenu.getText().equals("Bring to Front")) {
            frm.getSeletedShape().getParent().setComponentZOrder(frm.getSeletedShape(), 10);
        } else if (curMenu.getText().equals("Send to Back")) {
            frm.getSeletedShape().getParent().setComponentZOrder(frm.getSeletedShape(), 1);
        }
         else if (curMenu.getText().equals("Brightness")) {
            frm.setSelectedBandBrightness();
        }
        frm.getSelectedWorkArea().setSaved(false);
    }
}